package com.itheima.Test02;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Demo客户端02 {
    public static void main(String[] args) throws IOException {
        /*
        请编写客户端向服务器端上传的案例，要求上传完毕，
        服务器端要向客户端发送一条反馈信息，客户端收到反馈后打印到控制台，两端结束。
         */
        Socket s = new Socket("192.168.50.113",8899);
        //创建输入流;
        FileInputStream fis = new FileInputStream("D:\\Develop\\就业班资料\\Day18\\作业\\123.docx");
        //创建网络输出流;
        OutputStream os = s.getOutputStream();
        byte[] arr = new byte[1024];
        int i ;
        while ((i=fis.read(arr))!=-1){
            os.write(arr);
        }
        s.shutdownOutput();

        //创建输入流;
        InputStream iss = s.getInputStream();
        byte[] array = new byte[1024];
        int read = iss.read(array);
        System.out.println(new String(array,0,read));
        s.close();
        os.close();
        fis.close();
    }
}
